package com.Liuhang.Dao;

import com.Liuhang.JDBC.util;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

public class dep_insert extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ServletContext context = this.getServletContext();
        String dep_name = (String) req.getParameter("dep_name");
        String sql = "INSERT INTO `java01`.t_dep( dep_name) VALUES ('"+dep_name+"')";
        System.out.println(sql);
        try {
            Statement st = util.getStatement();
            st.execute(sql);
            st.close();
        } catch (SQLException | ClassNotFoundException throwables) {
            throwables.printStackTrace();
        }

    }
}
